<!DOCTYPE html>
<html lang="bg" id="project">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title><?php echo $this->translate('Admin panel'); ?></title>
		<meta name="keywords" content="" />
		<meta name="description" content="" />
		<link href="<?php echo LIGHT_ASSETS_URL; ?>/css/admin.css" rel="stylesheet" type="text/css"/>
		<script type="text/javascript" src="<?php echo LIGHT_ASSETS_URL; ?>/js/jquery-1.8.2.min.js"></script>
		<script type="text/javascript" src="<?php echo LIGHT_ASSETS_URL; ?>/js/jquery.blockUI.js"></script>
	</head>
	<body>
	<?php if ($this->identity()) : ?>
	    <table style="border-collapse: collapse; width: 100%">
	        <tr>
	            <td colspan="2">
                    <ul id="menu" style="float: left; margin: 0 0 10px 0; width: 98%;">
                    <?php if (LIGHT_LANGUAGE_ENABLE) : ?>
                        <li style="float: left;">
                        |
                        <?php foreach (array_keys(Light_Core::getTranslations()) as $lang) : ?>
                        <?php if (Light_Core::$mainController->getRequest()->getParam('lang') == $lang) : ?>
                            <?php echo $lang; ?> |
                        <?php else: ?>
                            <a href="<?php echo $this->url(array('lang' => $lang)); ?>"><?php echo $lang; ?></a> |
                        <?php endif; ?>
                        <?php endforeach; ?>
                        </li>
                    <?php endif; ?>
            	        <li style="float: left;">
                            <a href="<?php echo $this->url(array(), null, true); ?>"><?php echo $this->translate('Home'); ?></a>
                        </li>
                        <li style="float: left;">
                            <a href="<?php echo $this->url(array(), 'default'); ?>"><?php echo $this->translate('To Site'); ?></a>
                        </li>
                        <li style="float: left;">
                            <a href="<?php echo $this->url(array('module' => 'users', 'controller' => 'index', 'action' => 'logout'), null, true); ?>"><?php echo $this->translate('Logout'); ?></a>
                        </li>
                        <li style="float: right;">
                            <?php echo $this->translate('Welcome'); ?>,
                        <?php if ($this->identity()->firstName) : ?>
                            <?php echo $this->identity()->firstName; ?> <?php echo $this->identity()->middleName; ?> <?php echo $this->identity()->lastName; ?>
                        <?php else : ?>
                            <?php echo $this->identity()->name; ?>
                        <?php endif; ?>
                        </li>
                    </ul>
	            </td>
	        </tr>
    	    <tr>
    	        <td style="width: 300px; vertical-align: top;">
    	            <ul id="menu">
	                <?php
	                $modules = glob(LIGHT_APPLICATION_PATH . '/modules/*/controllers/admin/*');
	                if (is_array($modules) && !empty($modules)) :
    	                asort($modules);
    	                foreach ($modules as $module) :
    	                    $parts      = explode('/', $module);
    	                    $module     = $parts[count($parts) - 4];
    	                    $controller = $parts[count($parts) - 1];
    	                    $controller = substr($controller, 0, -4);
    	                    if ($module == 'default') :
    	                        if (in_array($controller, array('Index'))) :
    	                            continue;
                                endif;
    	                    endif;
                        ?>
    	                    <li><a href="<?php echo $this->url(array('module' => $module, 'controller' => strtolower($controller), 'action' => null), null, true); ?>">[<?php echo $this->translate(ucfirst($module)); ?>] <?php echo $this->translate($controller); ?></a></li>
                    <?php
                        endforeach;
                    endif;
                    ?>
                    </ul>
    	        </td>
    	        <td style="vertical-align: top;">
    	            <div id="content">
            	        <?php echo $this->flashMessage()->getMessage(); ?>
            		    <?php echo $this->content; ?>
            		</div>
    	        </td>
    	    </tr>
		</table>
	<?php else : ?>
		<?php echo $this->flashMessage()->getMessage(); ?>
	    <?php echo $this->content; ?>
	<?php endif; ?>
	</body>
</html>